import {request} from '@/utils/request'
import {getToken} from "@/utils/storage";


/**
 * @method addUserLogin 登录
 * @param {*} data
 * @returns
 */
export function addUserLogin(data) {
    return request({
        url: '/api/login',
        method: 'post',
        data
    })
}

/**
 * @method addUserInfo 用户信息
 * @param {*} data
 * @returns
 */
export function addUserInfo(data) {
    return request({
        url: '/api/user/info',
        method: 'get',
        headers: {"token": getToken()}
    })
}


/**
 * 分页
 * @param pageNum
 * @param pageSize
 * @param data
 */
export function pageList(data) {
    return request({
        url:`/api/user/page/${data.pageNum}/${data.pageSize}`,
        method: 'get',
        headers: {"token": getToken()},
        params: {
            username: data.username,
            nickname: data.nickname,
            phone: data.phone
        }
    })
}


export function clickStatus(id, status) {
    status = status == 0 ? 1 : 0
    return request({
        url:`/api/user/status/${id}/${status}`,
        method: 'get',
        headers: {"token": getToken()}
    })
}


export function removeById(id) {
    return request({
        url: `user/remove/${id}`,
        method: "delete",
        headers: {"token": getToken()}
    })
}

export function getUserByGradeId(id) {
    return request({
        url:`/api/user/getUserByGradeId/${id}`,
        method: "get",
        headers: {"token": getToken()}
    })
}
